

import React,{useState,useEffect} from 'react'
import axios from "axios";

export default function UseEffectDemo() {
  const [count,setCount] =  useState(1);
  const [limitNum,setLimitNum] =  useState(10);

  const [pros,setPros] = useState([]);

 useEffect(()=>{
  axios.get("http://121.89.205.189:3000/api/pro/list",{
    params:{
      count,limitNum
    }
  }).then(res=>{
    if(res.data.code==="200"){
      setPros(res.data.data);
    }
  })
 },[count,limitNum]);

  return (
    <>
      <div>useEffect</div>      
      第<input type="text" value={count} onChange={(ev)=>setCount(ev.target.value)} />页<br></br>
      每页<input type="text" value={limitNum} onChange={(ev)=>setLimitNum(ev.target.value)}  />条<br></br>
      <hr/>
      <ul>
        {
          pros.map(item=><li key={item.id}>{item.proid}</li>)
        }
        
      </ul>
     
    </>
  )
}